/*
 * @Author: Tendo 
 * @Date: 2021-09-10 11:03:25 
 * @param {ListNode} head
 * @param {number} n
 * @return {ListNode}
 */
var removeNthFromEnd = (head, n) => {
    let dummy = new ListNode(0, head),
        slow = dummy,
        fast = dummy;
    for (let i = 0; i < n+1; i++) {
        fast = fast.next
    }
    while(true) {
        if (fast.next != null) {
            slow = slow.next
            fast = fast.next
        } else {
            slow.next = slow.next.next
            break
        }        
    }
    return dummy.next;
}